package com.mapper.DaoImpl;

import com.Util.MybatisUtil;
import com.entity.User;
import com.mapper.UserMapper;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.Map;

public class UserMapperImpl implements UserMapper {

    private SqlSession session = MybatisUtil.getSession();

    @Override
    public User checkUser(String username, String password) {
        //定义map集合传递用户传递的数据
        Map<String, String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        //map集合存储key和Value必须是一一对象的映射关系,且key表示什么含义,对应的value就是什么值
        User one = session.selectOne("com.mapper.UserMapper.checkUser", map);
        return one;
    }

    @Override
    public void editHeadImg(User user_in_session) {
        session.update("com.mapper.UserMapper.editHeadImg", user_in_session);
        session.commit();
    }
}
